package com.loan.controller.common;

import com.alibaba.fastjson.JSONObject;
import com.loan.common.core.domain.Result;
import com.loan.system.service.ApplyService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author shiguang
 * @date 2022年09月16日 22:31
 */
@Api(value = "HqPay代收管理", tags = {"HqPay代收管理"})
@RequiredArgsConstructor
@RestController
@Slf4j
@RequestMapping("/api/hqpay")
public class HqPayController {

    private final ApplyService applyService;

    /**
     * 代收回调
     *
     * @return
     */
    @GetMapping(value = "/payment/callback", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result paymentCallBack(@RequestBody JSONObject jsonObject) {

        applyService.checkPaymentData(jsonObject.getJSONObject("data"), jsonObject.getString("signature"));
//        HQPayUtils.verifySign(null,paymentCallbackVo.getData(),paymentCallbackVo.getSignature());
        return Result.ok();
    }

    /**
     * 代收虚拟账户回调
     *
     * @return
     */
    @GetMapping(value = "/vaAccount/payment/callback")
    public Result vaAccountPaymentCallBack(String vaNumber) {
//        applyService.checkPaymentData(jsonObject.getJSONObject("data"), jsonObject.getString("signature"));
//        log.info("返回数据：",jsonObject.toString());
        log.info("返回数据：{}", vaNumber);
        return Result.ok();
    }
}
